
/* Written by Michael E. Kounavis based on the NIST cryptographic API, 
   Commmunications Technology Lab, Intel Corporation, 2008
 */

#ifndef SHA3_API_H
#define SHA3_API_H

#include "int_types.h"

#if 0
#define HAMMING_W_ANALYSIS
#endif

typedef unsigned char BitSequence;

typedef unsigned long long DataLength; // a typical 64-bit value 

typedef enum { SUCCESS = 0, 
			   FAIL = 1, 
			   BAD_HASHBITLEN = 2,
			   CALL_FAILURE	= 3,		//additional vortex implementation specific errors
			   INVALID_ROUNDS = 4,
			   INVALID_LENGTH = 5,
			   NULL_POINTER_ERROR = 6,
			   } HashReturn; 

typedef struct {
	 uint32_t	hashbitlen;
	 uint64_t	padding_length;
	 uint8_t    *hash; 					//vortex specific parameters
	 uint8_t    number_of_rounds;
     uint8_t    mul_type;
	 uint8_t    degree_of_diffusion;
	 uint8_t    *a0_b0;
	 uint8_t    *ta_tb;
      } hashState;

HashReturn Init(hashState *state, 
				int hashbitlen);

HashReturn Update(hashState *state, 
				  const BitSequence *data, 
				  DataLength databitlen);

HashReturn Final(hashState *state, 
				 BitSequence *hashval);

HashReturn Hash(int hashbitlen, 
				const BitSequence *data, 
				DataLength databitlen, 
				BitSequence *hashval);

#ifdef HAMMING_W_ANALYSIS
void
print_hamming_weight(BitSequence *data, int hashbitlen);

uint32_t
compute_hamming_weight(BitSequence *data, int length);
#endif

#endif